#include "front/text_normalize.h"

using namespace std;
using namespace ppspeech;

const wregex mcWregexDate(L"(\\d{4}|\\d{2})年((0?[1-9]|1[0-2])月)?(((0?[1-9])|((1|2)[0-9])|30|31)([日号]))?");
// 日期，2021年8月18日 --> 二零二一年八月十八日
void TextNormalizer::TnReChineseDate(wstring* fInWsentence, const LanguageEnum fcInLanguage)
{
	wsmatch tWsmatch;

	while (regex_search(*fInWsentence, tWsmatch, mcWregexDate)) {
		vector<string> tItemDate = {
			wstring2utf8string(tWsmatch[1]),
			wstring2utf8string(tWsmatch[3]),
			wstring2utf8string(tWsmatch[5]),
			wstring2utf8string(tWsmatch[9]),
		};

		string tStrReplace = ReplaceMethod(tItemDate, (fcInLanguage==LANG_EN)?RME_en_chinesedate:RME_zh_chinesedate);

		WstrReplacePosition(fInWsentence, tWsmatch.position(0), tWsmatch.length(0), utf8string2wstring(tStrReplace));
	}
}
